package com.chat.login.controller;

import com.chat.common.vo.R;
import com.chat.login.service.GroupService;
import jakarta.validation.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * AuthGroup
 */
@RestController
@Validated
@RequestMapping("/auth/group")
public class GroupController {

    @Autowired
    GroupService groupService;

    /**
     * 根据群号获取对应的冻结原因
     * @param groupAccount
     * @return
     */
    @GetMapping("/getGroupDisable")
    public R getGroupByAccount(@RequestParam @NotBlank(message = "群聊号不能为空") String groupAccount) {
        return groupService.getGroupByAccount(groupAccount);
    }

    /**
     * 判断账号是否是群主
     * @param account
     * @return
     */
    @GetMapping("/getGroupByGroupLeader")
    public R getGroupByGroupLeader(@RequestParam @NotBlank(message = "账号不能为空") String account,@RequestParam @NotBlank(message = "群聊号不能为空") String groupAccount) {
        return groupService.getGroupByGroupLeader(account,groupAccount);
    }
}
